package spring;

import spring.controller.MyWeb;

/**
 * User  yyl
 * Description:     测试Di
 * Created by yaoyonglong on 2018/11/1 9:50
 */
public class Start {
    public static void main(String[] args) {
        //创建AnnotationConfigApplicationContext对象
//        App ctx = new App("spring");
        AppDemo ctx = new AppDemo("spring");
        //仅使用key作为参数获取对象，需要强转
//        SingletonUser singletonUser1 = (SingletonUser) ctx.getBean("singletonUser");
//        System.out.println("单例User对象:" + singletonUser1);
//        //使用key和类对象作为参数获取对象，无需强转
//        SingletonUser singletonUser2 = ctx.getBean("singletonUser", SingletonUser.class);
//        System.out.println("单例User对象:" + singletonUser2);
//
//        //仅使用key作为参数获取对象，需要强转
//        PrototypeUser prototypeUser1 = (PrototypeUser) ctx.getBean("prototypeUser");
//        System.out.println("多例User对象:" + prototypeUser1);
//        //使用key和类对象作为参数获取对象，无需强转
//        PrototypeUser prototypeUser2 = ctx.getBean("prototypeUser", PrototypeUser.class);
//        System.out.println("多例User对象:" + prototypeUser2);

        MyWeb myservice = ctx.getBean("myWeb", MyWeb.class);

        String url = myservice.getUrl();
        System.out.println(url);
        //销毁资源
        ctx.close();
    }
}
